<template>
	<view class="detail">
		<text class="title">{{detai.title}}</text>
		<view class="info">
			<text decode>发表时间:</text> <text>{{detai.add_time | formatDate}}</text>
			<text decode space="nbsp">浏览:  </text> <text>{{detai.click}}</text>
		</view>
		<view class="content">
			<rich-text :nodes="detai.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				detai:{}
			}
		},
		filters:{
			formatDate (date) {
				const nDate = new Date(date)
				const year = nDate.getFullYear()
				const month = nDate.getMonth().toString().padStart(2,0)
				const day = nDate.getDay().toString().padStart(2,0)
				return year+'-'+month+'-'+day
			}
		},
		onLoad(options){
			this.getDetailMsg(options.id)
			
		},
		methods:{
			async getDetailMsg(id){
				console.log(id)
			const res= await this.$myRequest({
					url:`/api/getnew/${id}`
				})
			 this.detai=res.data.message[0]
			
			}
		}
	}
</script>

<style lang="scss">
	.detail{
		padding: 20rpx 10rpx 0;
		.title{
			display: block;
			text-align: center;
			font-size:36rpx;
			font-weight: 700;
		}
		.info{
			margin-top:20rpx;
			text:nth-child(1){
				margin-left:80rpx
			}
			text:nth-child(2){
			margin: 0 30rpx;
			}
			text:nth-child(3){
			margin-right:30rpx;
			margin-left: 20rpx;
			}
			text:nth-child(odd){
				font-size:30rpx;
				color:eee;
			}
		}
		.content{
			margin-top:20rpx;
		}
	}
</style>
